/**
  *@file    drv_key.c
  *@brief   driver IWDG interface
  *@create  zxf 2021-06-21
  *@version V1.0.0
  *@note    none
  */
#include "board_pin.h"
#include "drv_wdt.h"

/* Private define ---------------------------------------*/
/* Private macro ----------------------------------------*/
/* Private typedef --------------------------------------*/
/* Private variables ------------------------------------*/
/* Private function prototypes --------------------------*/
/* Interface variables ----------------------------------*/

/* Interface functions ----------------------------------*/

//Fsrc=32768Hz  Tout=cnt*div/Fsrc(s)
//cnt:75=300ms, 384=1.5s
void drvWdt_Init(void)
{
    RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_PWR, ENABLE);
    DBG_ConfigPeriph(DBG_IWDG_STOP, ENABLE);
    
	IWDG_WriteConfig(IWDG_WRITE_ENABLE);
    
    IWDG_SetPrescalerDiv(IWDG_PRESCALER_DIV128);
    
    IWDG_CntReload(384);
    
    IWDG_ReloadKey();
    
    IWDG_Enable();
}

void drvWdt_Feed(void)
{
	IWDG_ReloadKey();
}

/* Private functions ------------------------------------*/



